text
stringlengths
96
319k
id
stringlengths
14
178
metadata
dict
# Copyright 2024 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
accelerate/benchmarks/fp8/transformer_engine/fp8_utils.py/0
{ "file_path": "accelerate/benchmarks/fp8/transformer_engine/fp8_utils.py", "repo_id": "accelerate", "token_count": 1601 }
<!--Copyright 2021 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
accelerate/docs/source/package_reference/cli.md/0
{ "file_path": "accelerate/docs/source/package_reference/cli.md", "repo_id": "accelerate", "token_count": 5970 }
<!-- Copyright 2022 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agree...
accelerate/docs/source/usage_guides/ddp_comm_hook.md/0
{ "file_path": "accelerate/docs/source/usage_guides/ddp_comm_hook.md", "repo_id": "accelerate", "token_count": 3366 }
<!--Copyright 2022 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
accelerate/docs/source/usage_guides/tracking.md/0
{ "file_path": "accelerate/docs/source/usage_guides/tracking.md", "repo_id": "accelerate", "token_count": 2703 }
# Copyright 2022 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
accelerate/examples/by_feature/multi_process_metrics.py/0
{ "file_path": "accelerate/examples/by_feature/multi_process_metrics.py", "repo_id": "accelerate", "token_count": 3665 }
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/examples/multigpu_remote_launcher.py/0
{ "file_path": "accelerate/examples/multigpu_remote_launcher.py", "repo_id": "accelerate", "token_count": 1026 }
# Copyright 2024 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/manim_animations/dataloaders/stage_3.py/0
{ "file_path": "accelerate/manim_animations/dataloaders/stage_3.py", "repo_id": "accelerate", "token_count": 577 }
#!/usr/bin/env python # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
accelerate/src/accelerate/commands/config/config_args.py/0
{ "file_path": "accelerate/src/accelerate/commands/config/config_args.py", "repo_id": "accelerate", "token_count": 4284 }
#!/usr/bin/env python # Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
accelerate/src/accelerate/commands/tpu.py/0
{ "file_path": "accelerate/src/accelerate/commands/tpu.py", "repo_id": "accelerate", "token_count": 2114 }
# Copyright 2022 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
accelerate/src/accelerate/test_utils/scripts/external_deps/test_checkpointing.py/0
{ "file_path": "accelerate/src/accelerate/test_utils/scripts/external_deps/test_checkpointing.py", "repo_id": "accelerate", "token_count": 4199 }
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/src/accelerate/test_utils/training.py/0
{ "file_path": "accelerate/src/accelerate/test_utils/training.py", "repo_id": "accelerate", "token_count": 2582 }
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/src/accelerate/utils/other.py/0
{ "file_path": "accelerate/src/accelerate/utils/other.py", "repo_id": "accelerate", "token_count": 4783 }
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/tests/test_cli.py/0
{ "file_path": "accelerate/tests/test_cli.py", "repo_id": "accelerate", "token_count": 9247 }
# Copyright 2024 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/tests/test_logging.py/0
{ "file_path": "accelerate/tests/test_logging.py", "repo_id": "accelerate", "token_count": 1156 }
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/tests/test_utils.py/0
{ "file_path": "accelerate/tests/test_utils.py", "repo_id": "accelerate", "token_count": 10075 }
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the ...
candle/LICENSE-MIT/0
{ "file_path": "candle/LICENSE-MIT", "repo_id": "candle", "token_count": 263 }
# Training Training starts with data. We're going to use the huggingface hub and start with the Hello world dataset of machine learning, MNIST. Let's start with downloading `MNIST` from [huggingface](https://huggingface.co/datasets/mnist). This requires [`hf-hub`](https://github.com/huggingface/hf-hub). ```bash ca...
candle/candle-book/src/training/training.md/0
{ "file_path": "candle/candle-book/src/training/training.md", "repo_id": "candle", "token_count": 361 }
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use std::str::FromStr; use anyhow::Result; use candle_core::{Device, Tensor}; fn cos_sin(n: usize, device: &Device) -> Result<Tensor> { let thetas: Vec<_> = (0..n).map(|i| (i as f32 / n as f32)).colle...
candle/candle-core/examples/cuda_sum_benchmark.rs/0
{ "file_path": "candle/candle-core/examples/cuda_sum_benchmark.rs", "repo_id": "candle", "token_count": 827 }
use crate::backend::BackendDevice; use crate::{CpuStorage, CpuStorageRef, DType, Layout, Result, Shape}; pub use candle_kernels as kernels; pub use cudarc; use cudarc::driver::{CudaFunction, LaunchAsync, LaunchConfig}; use half::{bf16, f16}; use std::sync::{Arc, Mutex}; use super::{CudaError, CudaStorage, CudaStorageS...
candle/candle-core/src/cuda_backend/device.rs/0
{ "file_path": "candle/candle-core/src/cuda_backend/device.rs", "repo_id": "candle", "token_count": 9908 }
#![allow(dead_code)] use libc::{c_char, c_double, c_float, c_int}; mod ffi { use super::*; extern "C" { pub fn vsTanh(n: c_int, a: *const c_float, y: *mut c_float); pub fn vdTanh(n: c_int, a: *const c_double, y: *mut c_double); pub fn vsExp(n: c_int, a: *const c_float, y: *mut c_float);...
candle/candle-core/src/mkl.rs/0
{ "file_path": "candle/candle-core/src/mkl.rs", "repo_id": "candle", "token_count": 6463 }
//! Module to load `safetensor` files into CPU/GPU memory. //! //! There are multiple ways to load tensors from safetensor files: //! - `load` function for loading directly into memory and returning a HashMap of tensors //! - `MmapedSafetensors` for memory mapping files and avoiding full allocation //! - `SliceSafetens...
candle/candle-core/src/safetensors.rs/0
{ "file_path": "candle/candle-core/src/safetensors.rs", "repo_id": "candle", "token_count": 8223 }
#![allow(clippy::approx_constant)] use anyhow::{Context, Result}; use candle_core::{test_device, test_utils, Device, Shape, Tensor, Var}; fn simple_grad(device: &Device) -> Result<()> { let x = Var::new(&[3f32, 1., 4.], device)?; let x = x.as_tensor(); let y = (((x * x)? + x * 5f64)? + 4f64)?; let grad...
candle/candle-core/tests/grad_tests.rs/0
{ "file_path": "candle/candle-core/tests/grad_tests.rs", "repo_id": "candle", "token_count": 9105 }
# candle-bert Bert is a general large language model. In this example it can be used for two different tasks: - Compute sentence embeddings for a prompt. - Compute similarities between a set of sentences. ## Sentence embeddings Bert is used to compute the sentence embeddings for a prompt. The model weights are down...
candle/candle-examples/examples/bert/README.md/0
{ "file_path": "candle/candle-examples/examples/bert/README.md", "repo_id": "candle", "token_count": 1564 }
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use clap::{Parser, ValueEnum}; use candle::{DType, IndexOp, D}; use candle_nn::{Module, VarBuilder}; use candle_transformers::models::convnext; #[derive(Clone, Copy, Debug, ValueEnum)] enum Which { At...
candle/candle-examples/examples/convnext/main.rs/0
{ "file_path": "candle/candle-examples/examples/convnext/main.rs", "repo_id": "candle", "token_count": 1926 }
//! EfficientNet implementation. //! //! https://arxiv.org/abs/1905.11946 #[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::{DType, IndexOp, D}; use candle_nn::{Module, VarBuilder}; use candle_transformers::models::efficientnet::{EfficientNet,...
candle/candle-examples/examples/efficientnet/main.rs/0
{ "file_path": "candle/candle-examples/examples/efficientnet/main.rs", "repo_id": "candle", "token_count": 1421 }
// https://github.com/karpathy/llama2.c #[cfg(feature = "accelerate")] extern crate accelerate_src; #[cfg(feature = "mkl")] extern crate intel_mkl_src; use candle_transformers::models::llama2_c as model; use candle_transformers::models::llama2_c_weights as weights; use candle_transformers::models::quantized_llama2_c...
candle/candle-examples/examples/llama2-c/main.rs/0
{ "file_path": "candle/candle-examples/examples/llama2-c/main.rs", "repo_id": "candle", "token_count": 6004 }
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::Error as E; use clap::{Parser, ValueEnum}; use candle::{DType, Tensor}; use candle_examples::token_output_stream::TokenOutputStream; use candle_nn::VarBuilder; use candle_transformers::models::...
candle/candle-examples/examples/marian-mt/main.rs/0
{ "file_path": "candle/candle-examples/examples/marian-mt/main.rs", "repo_id": "candle", "token_count": 2385 }
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use clap::{Parser, ValueEnum}; use candle::{DType, IndexOp, D}; use candle_nn::{Module, VarBuilder}; use candle_transformers::models::mobileone; #[derive(Clone, Copy, Debug, ValueEnum)] enum Which { S...
candle/candle-examples/examples/mobileone/main.rs/0
{ "file_path": "candle/candle-examples/examples/mobileone/main.rs", "repo_id": "candle", "token_count": 1213 }
# candle-parler-tts [Parler-TTS](https://huggingface.co/parler-tts/parler-tts-large-v1) is a large text-to-speech model with 2.2B parameters trained on ~45K hours of audio data. The voice can be controlled by a text prompt. ## Run an example ```bash cargo run --example parler-tts -r -- \ --prompt "Hey, how are you...
candle/candle-examples/examples/parler-tts/README.md/0
{ "file_path": "candle/candle-examples/examples/parler-tts/README.md", "repo_id": "candle", "token_count": 260 }
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::{Error as E, Result}; use clap::Parser; use candle_transformers::models::qwen2::{Config as ConfigBase, ModelForCausalLM as ModelBase}; use candle_transformers::models::qwen2_moe::{Config as Con...
candle/candle-examples/examples/qwen/main.rs/0
{ "file_path": "candle/candle-examples/examples/qwen/main.rs", "repo_id": "candle", "token_count": 4905 }
# This script exports pre-trained model weights in the safetensors format. import numpy as np import torch import torchvision from safetensors import torch as stt m = torchvision.models.resnet50(pretrained=True) stt.save_file(m.state_dict(), 'resnet50.safetensors') m = torchvision.models.resnet101(pretrained=True) stt...
candle/candle-examples/examples/resnet/export_models.py/0
{ "file_path": "candle/candle-examples/examples/resnet/export_models.py", "repo_id": "candle", "token_count": 166 }
# candle-splade SPLADE is a neural retrieval model which learns query/document sparse expansion via the BERT MLM head and sparse regularization. Sparse representations benefit from several advantages compared to dense approaches: efficient use of inverted index, explicit lexical match, interpretability... They also s...
candle/candle-examples/examples/splade/README.md/0
{ "file_path": "candle/candle-examples/examples/splade/README.md", "repo_id": "candle", "token_count": 474 }
# candle-t5 ## Encoder-decoder example: ```bash $ cargo run --example t5 --release -- --model-id "t5-small" --prompt "translate to German: A beautiful candle." --decode ... Eine schöne Kerze. 9 tokens generated (2.42 token/s) ``` Variants such as [flan-t5](https://huggingface.co/google/flan-t5-small), [flan-ul2](ht...
candle/candle-examples/examples/t5/README.md/0
{ "file_path": "candle/candle-examples/examples/t5/README.md", "repo_id": "candle", "token_count": 608 }
#include <cmath> #include <cute/tensor.hpp> #include <cutlass/cutlass.h> #include <cutlass/array.h> #include "utils.h" namespace flash { using namespace cute; //////////////////////////////////////////////////////////////////////////////////////////////////// template <bool Is_causal> struct Alibi { const f...
candle/candle-flash-attn/kernels/alibi.h/0
{ "file_path": "candle/candle-flash-attn/kernels/alibi.h", "repo_id": "candle", "token_count": 1556 }
// Copyright (c) 2024, Tri Dao. // Splitting the different head dimensions to different files to speed up compilation. // This file is auto-generated. See "generate_kernels.py" #include "flash_fwd_launch_template.h" template<> void run_mha_fwd_<cutlass::half_t, 192, true>(Flash_fwd_params &params, cudaStream_t stream...
candle/candle-flash-attn/kernels/flash_fwd_hdim192_fp16_causal_sm80.cu/0
{ "file_path": "candle/candle-flash-attn/kernels/flash_fwd_hdim192_fp16_causal_sm80.cu", "repo_id": "candle", "token_count": 138 }
/****************************************************************************** * Copyright (c) 2024, Tri Dao. ******************************************************************************/ #pragma once #include <cmath> #include <cute/tensor.hpp> #include <cutlass/numeric_types.h> #include "philox.cuh" #include...
candle/candle-flash-attn/kernels/softmax.h/0
{ "file_path": "candle/candle-flash-attn/kernels/softmax.h", "repo_id": "candle", "token_count": 4008 }
#include<stdint.h> #include "cuda_fp16.h" template<typename T> __device__ void fill_with(T *buf, T value, const size_t numel) { for (unsigned int i = blockIdx.x * blockDim.x + threadIdx.x; i < numel; i += blockDim.x * gridDim.x) { buf[i] = value; } } extern "C" __global__ void fill_u8(uint8_t *buf, uin...
candle/candle-kernels/src/fill.cu/0
{ "file_path": "candle/candle-kernels/src/fill.cu", "repo_id": "candle", "token_count": 919 }
#include <metal_stdlib> using namespace metal; METAL_FUNC uint get_strided_index( uint idx, constant size_t &num_dims, constant size_t *dims, constant size_t *strides ) { uint strided_i = 0; for (uint d = 0; d < num_dims; d++) { uint dim_idx = num_dims - 1 - d; strided_i += (idx...
candle/candle-metal-kernels/src/indexing.metal/0
{ "file_path": "candle/candle-metal-kernels/src/indexing.metal", "repo_id": "candle", "token_count": 4200 }
use candle_metal_kernels::{call_affine, Kernels}; use metal::objc::rc::autoreleasepool; use metal::{Device, MTLResourceOptions}; use rand; use std::any::type_name; use std::time::Instant; fn main() { let device = Device::system_default().unwrap(); let kernels = Kernels::new(); let f32_1k = (0..1000).map(|...
candle/candle-metal-kernels/tmp/affine.rs/0
{ "file_path": "candle/candle-metal-kernels/tmp/affine.rs", "repo_id": "candle", "token_count": 1154 }
//! Embedding Layer. use candle::{Result, Tensor}; #[derive(Clone, Debug)] pub struct Embedding { embeddings: Tensor, hidden_size: usize, } impl Embedding { pub fn new(embeddings: Tensor, hidden_size: usize) -> Self { Self { embeddings, hidden_size, } } pub...
candle/candle-nn/src/embedding.rs/0
{ "file_path": "candle/candle-nn/src/embedding.rs", "repo_id": "candle", "token_count": 571 }
//! A `VarMap` is a store that holds named variables. //! use candle::{DType, Device, Result, Shape, Tensor, Var}; use std::collections::HashMap; use std::sync::{Arc, Mutex}; /// A `VarMap` is a store that holds named variables. Variables can be retrieved from the stores /// and new variables can be added by providing...
candle/candle-nn/src/var_map.rs/0
{ "file_path": "candle/candle-nn/src/var_map.rs", "repo_id": "candle", "token_count": 1992 }
// // WARNING: This file is automatically generated! Please edit onnx.in.proto. // // SPDX-License-Identifier: Apache-2.0 syntax = "proto3"; package onnx; // Overview // // ONNX is an open specification that is comprised of the following components: // // 1) A definition of an extensible computation graph model...
candle/candle-onnx/src/onnx.proto3/0
{ "file_path": "candle/candle-onnx/src/onnx.proto3", "repo_id": "candle", "token_count": 10183 }
# Generated content DO NOT EDIT from typing import Any, Callable, Dict, List, Optional, Tuple, Union, Sequence from os import PathLike from candle.typing import _ArrayLike, Device, Scalar, Index, Shape from candle import Tensor, DType, QTensor @staticmethod def silu(tensor: Tensor) -> Tensor: """ Applies the S...
candle/candle-pyo3/py_src/candle/nn/__init__.pyi/0
{ "file_path": "candle/candle-pyo3/py_src/candle/nn/__init__.pyi", "repo_id": "candle", "token_count": 181 }
use ::candle::Tensor; use pyo3::prelude::*; #[derive(Clone, Debug)] /// Represents an absolute shape e.g. (1, 2, 3) pub struct PyShape(Vec<usize>); impl<'source> pyo3::FromPyObject<'source> for PyShape { fn extract_bound(ob: &Bound<'source, PyAny>) -> PyResult<Self> { if ob.is_none() { return ...
candle/candle-pyo3/src/shape.rs/0
{ "file_path": "candle/candle-pyo3/src/shape.rs", "repo_id": "candle", "token_count": 1664 }
//! Based from the Stanford Hazy Research group. //! //! See "Simple linear attention language models balance the recall-throughput tradeoff", Arora et al. 2024 //! - Simple linear attention language models balance the recall-throughput tradeoff. [Arxiv](https://arxiv.org/abs/2402.18668) //! - [Github Rep](https://gith...
candle/candle-transformers/src/models/based.rs/0
{ "file_path": "candle/candle-transformers/src/models/based.rs", "repo_id": "candle", "token_count": 9967 }
//! ConvNeXt implementation. //! //! This candle implementation uses a pre-trained ConvNeXt network for inference. The //! classification head has been trained on the ImageNet dataset and returns the //! probabilities for the top-5 classes. //! //! Original code: //! - 💻 [ConvNeXt](https://github.com/facebookresearch/...
candle/candle-transformers/src/models/convnext.rs/0
{ "file_path": "candle/candle-transformers/src/models/convnext.rs", "repo_id": "candle", "token_count": 4949 }
use super::model::{attention, timestep_embedding, Config, EmbedNd}; use crate::quantized_nn::{linear, linear_b, Linear}; use crate::quantized_var_builder::VarBuilder; use candle::{DType, IndexOp, Result, Tensor, D}; use candle_nn::{LayerNorm, RmsNorm}; fn layer_norm(dim: usize, vb: VarBuilder) -> Result<LayerNorm> { ...
candle/candle-transformers/src/models/flux/quantized_model.rs/0
{ "file_path": "candle/candle-transformers/src/models/flux/quantized_model.rs", "repo_id": "candle", "token_count": 7943 }
//! Marian Neural Machine Translation //! //! See "Marian: Fast Neural Machine Translation in C++" Junczys-Dowmunt et al. 2018 //! - [ACL Anthology](https://aclanthology.org/P18-4020/) //! - [Github](https://github.com/marian-nmt/marian) //! use super::with_tracing::{linear, Embedding, Linear}; use candle::{Result, Ten...
candle/candle-transformers/src/models/marian.rs/0
{ "file_path": "candle/candle-transformers/src/models/marian.rs", "repo_id": "candle", "token_count": 9013 }
//! Mobile CLIP model, combining a lightweight vision encoder with a text encoder //! //! A mobile-optimized CLIP implementation that uses: //! - FastViT as the vision encoder //! - OpenCLIP text encoder //! - Projection layers to align the feature spaces //! //! See model details at: //! - [FastViT](https://arxiv.org/...
candle/candle-transformers/src/models/mobileclip.rs/0
{ "file_path": "candle/candle-transformers/src/models/mobileclip.rs", "repo_id": "candle", "token_count": 1499 }
//! Microsoft Phi model implementation //! //! The Phi series are decoder-only transformers designed for code and language tasks. //! //! Key characteristics: //! - Decoder-only transformer architecture //! - RoPE embeddings //! - Layer normalization //! - QK normalization //! //! - ⚡ [Interactive Wasm Example](https:/...
candle/candle-transformers/src/models/phi.rs/0
{ "file_path": "candle/candle-transformers/src/models/phi.rs", "repo_id": "candle", "token_count": 6213 }
//! Qwen2 model implementation with quantization support. //! //! Qwen2 is a chat-optimized language model that supports 8-bit quantization //! for reduced memory usage and faster inference. //! //! Key characteristics: //! - Group Query Attention (GQA) //! - RMSNorm for layer normalization //! - Rotary positional embe...
candle/candle-transformers/src/models/quantized_qwen2.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_qwen2.rs", "repo_id": "candle", "token_count": 6400 }
//! Segment Anything Model (SAM) //! //! SAM is an architecture for image segmentation, capable of segmenting any object //! in an image based on prompts like points or boxes. //! This model provides a robust and fast image segmentation pipeline that can be tweaked via //! some prompting (requesting some points to be i...
candle/candle-transformers/src/models/segment_anything/mod.rs/0
{ "file_path": "candle/candle-transformers/src/models/segment_anything/mod.rs", "repo_id": "candle", "token_count": 1721 }
//! 2D UNet Building Blocks //! use super::attention::{ AttentionBlock, AttentionBlockConfig, SpatialTransformer, SpatialTransformerConfig, }; use super::resnet::{ResnetBlock2D, ResnetBlock2DConfig}; use crate::models::with_tracing::{conv2d, Conv2d}; use candle::{Module, Result, Tensor, D}; use candle_nn as nn; #[...
candle/candle-transformers/src/models/stable_diffusion/unet_2d_blocks.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/unet_2d_blocks.rs", "repo_id": "candle", "token_count": 13813 }
use candle::{Module, Result, Tensor}; use candle_nn::{linear, Linear, VarBuilder}; // A simplified version of: // https://github.com/huggingface/diffusers/blob/119ad2c3dc8a8fb8446a83f4bf6f20929487b47f/src/diffusers/models/attention_processor.py#L38 #[derive(Debug)] pub struct Attention { to_q: Linear, to_k: Li...
candle/candle-transformers/src/models/wuerstchen/attention_processor.rs/0
{ "file_path": "candle/candle-transformers/src/models/wuerstchen/attention_processor.rs", "repo_id": "candle", "token_count": 2076 }
use candle::Result; use candle_transformers::object_detection::{ non_maximum_suppression, soft_non_maximum_suppression, Bbox, }; #[test] fn nms_basic() -> Result<()> { // Boxes based upon https://thepythoncode.com/article/non-maximum-suppression-using-opencv-in-python let mut bboxes = vec![vec![ Bb...
candle/candle-transformers/tests/nms_tests.rs/0
{ "file_path": "candle/candle-transformers/tests/nms_tests.rs", "repo_id": "candle", "token_count": 3139 }
use candle::Result; /// This is a wrapper around a tokenizer to ensure that tokens can be returned to the user in a /// streaming way rather than having to wait for the full decoding. pub struct TokenOutputStream { tokenizer: tokenizers::Tokenizer, tokens: Vec<u32>, prev_index: usize, current_index: us...
candle/candle-wasm-examples/blip/src/token_output_stream.rs/0
{ "file_path": "candle/candle-wasm-examples/blip/src/token_output_stream.rs", "repo_id": "candle", "token_count": 1295 }
<html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> <title>Candle Segment Anything Model (SAM) Rust/WASM</title> </head> <body></body> </html> <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1...
candle/candle-wasm-examples/segment-anything/lib-example.html/0
{ "file_path": "candle/candle-wasm-examples/segment-anything/lib-example.html", "repo_id": "candle", "token_count": 10333 }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Welcome to Candle!</title> <link data-trunk rel="copy-file" href="yolov8s.safetensors" /> <link data-trunk rel="copy-file" href="bike.jpeg" /> <link data-trunk rel="rust" href="Cargo.toml" data-bin="app" data-type="main" /> ...
candle/candle-wasm-examples/yolo/index.html/0
{ "file_path": "candle/candle-wasm-examples/yolo/index.html", "repo_id": "candle", "token_count": 322 }
[package] name = "tensor-tools" version.workspace = true edition.workspace = true description.workspace = true repository.workspace = true keywords.workspace = true categories.workspace = true license.workspace = true [dependencies] anyhow = { workspace = true } candle = { workspace = true } clap = { workspace = true ...
candle/tensor-tools/Cargo.toml/0
{ "file_path": "candle/tensor-tools/Cargo.toml", "repo_id": "candle", "token_count": 119 }
apiVersion: apps/v1 kind: Deployment metadata: labels: {{ include "labels.standard" . | nindent 4 }} name: {{ include "name" . }} namespace: {{ .Release.Namespace }} {{- if .Values.infisical.enabled }} annotations: secrets.infisical.com/auto-reload: "true" {{- end }} spec: progressDeadlineSeconds: 600...
chat-ui/chart/templates/deployment.yaml/0
{ "file_path": "chat-ui/chart/templates/deployment.yaml", "repo_id": "chat-ui", "token_count": 1334 }
# Amazon Web Services (AWS) | Feature | Available | | --------------------------- | --------- | | [Tools](../tools) | No | | [Multimodal](../multimodal) | No | You may specify your Amazon SageMaker instance as an endpoint for Chat UI: ```ini MODELS=`[{ "name": "your-mode...
chat-ui/docs/source/configuration/models/providers/aws.md/0
{ "file_path": "chat-ui/docs/source/configuration/models/providers/aws.md", "repo_id": "chat-ui", "token_count": 348 }
# 🤗 Chat UI Open source chat interface with support for tools, web search, multimodal and many API providers. The app uses MongoDB and SvelteKit behind the scenes. Try the live version of the app called [HuggingChat on hf.co/chat](https://huggingface.co/chat) or [setup your own instance](./installation/spaces). 🔧 *...
chat-ui/docs/source/index.md/0
{ "file_path": "chat-ui/docs/source/index.md", "repo_id": "chat-ui", "token_count": 1435 }
export function clickOutside(element: HTMLElement, callbackFunction: () => void) { function onClick(event: MouseEvent) { if (!element.contains(event.target as Node)) { callbackFunction(); } } document.body.addEventListener("click", onClick); return { update(newCallbackFunction: () => void) { callbackF...
chat-ui/src/lib/actions/clickOutside.ts/0
{ "file_path": "chat-ui/src/lib/actions/clickOutside.ts", "repo_id": "chat-ui", "token_count": 144 }
<script lang="ts"> import CarbonEarth from "~icons/carbon/earth"; import CarbonArrowUpRight from "~icons/carbon/arrow-up-right"; import BIMeta from "~icons/bi/meta"; import CarbonCode from "~icons/carbon/code"; import type { Model } from "$lib/types/Model"; interface Props { model: Pick< Model, "name" | ...
chat-ui/src/lib/components/ModelCardMetadata.svelte/0
{ "file_path": "chat-ui/src/lib/components/ModelCardMetadata.svelte", "repo_id": "chat-ui", "token_count": 901 }
<script lang="ts"> import CarbonWikis from "~icons/carbon/wikis"; import CarbonTools from "~icons/carbon/tools"; import CarbonCamera from "~icons/carbon/camera"; import CarbonCode from "~icons/carbon/code"; import CarbonEmail from "~icons/carbon/email"; import CarbonCloud from "~icons/carbon/cloud-upload"; impor...
chat-ui/src/lib/components/ToolLogo.svelte/0
{ "file_path": "chat-ui/src/lib/components/ToolLogo.svelte", "repo_id": "chat-ui", "token_count": 1446 }
<script lang="ts"> import { createEventDispatcher } from "svelte"; import { page } from "$app/stores"; import type { MessageFile } from "$lib/types/Message"; import CarbonClose from "~icons/carbon/close"; import CarbonDocumentBlank from "~icons/carbon/document-blank"; import CarbonDownload from "~icons/carbon/dow...
chat-ui/src/lib/components/chat/UploadedFile.svelte/0
{ "file_path": "chat-ui/src/lib/components/chat/UploadedFile.svelte", "repo_id": "chat-ui", "token_count": 3554 }
import type { ObjectId } from "mongodb"; import updateSearchAssistant from "./01-update-search-assistants"; import updateAssistantsModels from "./02-update-assistants-models"; import type { Database } from "$lib/server/database"; import addToolsToSettings from "./03-add-tools-in-settings"; import updateMessageUpdates ...
chat-ui/src/lib/migrations/routines/index.ts/0
{ "file_path": "chat-ui/src/lib/migrations/routines/index.ts", "repo_id": "chat-ui", "token_count": 376 }
import { z } from "zod"; import { env } from "$env/dynamic/private"; import type { Endpoint } from "../endpoints"; import type { TextGenerationStreamOutput } from "@huggingface/inference"; import type { Cohere, CohereClient } from "cohere-ai"; import { buildPrompt } from "$lib/buildPrompt"; import { ToolResultStatus, t...
chat-ui/src/lib/server/endpoints/cohere/endpointCohere.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/cohere/endpointCohere.ts", "repo_id": "chat-ui", "token_count": 2221 }
import type { Conversation } from "$lib/types/Conversation"; import type { MessageFile } from "$lib/types/Message"; import { sha256 } from "$lib/utils/sha256"; import { fileTypeFromBuffer } from "file-type"; import { collections } from "$lib/server/database"; export async function uploadFile(file: File, conv: Conversa...
chat-ui/src/lib/server/files/uploadFile.ts/0
{ "file_path": "chat-ui/src/lib/server/files/uploadFile.ts", "repo_id": "chat-ui", "token_count": 364 }
import { env } from "$env/dynamic/private"; import { logger } from "$lib/server/logger"; export async function sendSlack(text: string) { if (!env.WEBHOOK_URL_REPORT_ASSISTANT) { logger.warn("WEBHOOK_URL_REPORT_ASSISTANT is not set, tried to send a slack message."); return; } const res = await fetch(env.WEBHOOK...
chat-ui/src/lib/server/sendSlack.ts/0
{ "file_path": "chat-ui/src/lib/server/sendSlack.ts", "repo_id": "chat-ui", "token_count": 226 }
import { z } from "zod"; import { env } from "$env/dynamic/private"; import JSON5 from "json5"; // RATE_LIMIT is the legacy way to define messages per minute limit export const usageLimitsSchema = z .object({ conversations: z.coerce.number().optional(), // how many conversations messages: z.coerce.number().option...
chat-ui/src/lib/server/usageLimits.ts/0
{ "file_path": "chat-ui/src/lib/server/usageLimits.ts", "repo_id": "chat-ui", "token_count": 309 }
import type { WebSearchSource } from "$lib/types/WebSearch"; import { env } from "$env/dynamic/private"; export default async function search(query: string): Promise<WebSearchSource[]> { // const params = { // q: query, // // You can add other parameters if needed, like 'count', 'offset', etc. // }; cons...
chat-ui/src/lib/server/websearch/search/endpoints/bing.ts/0
{ "file_path": "chat-ui/src/lib/server/websearch/search/endpoints/bing.ts", "repo_id": "chat-ui", "token_count": 408 }
import { browser } from "$app/environment"; import { invalidate } from "$app/navigation"; import { base } from "$app/paths"; import { UrlDependency } from "$lib/types/UrlDependency"; import type { ObjectId } from "mongodb"; import { getContext, setContext } from "svelte"; import { type Writable, writable, get } from "s...
chat-ui/src/lib/stores/settings.ts/0
{ "file_path": "chat-ui/src/lib/stores/settings.ts", "repo_id": "chat-ui", "token_count": 1007 }
const file2base64 = (file: File): Promise<string> => { return new Promise<string>((resolve, reject) => { const reader = new FileReader(); reader.readAsDataURL(file); reader.onload = () => { const dataUrl = reader.result as string; const base64 = dataUrl.split(",")[1]; resolve(base64); }; reader.oner...
chat-ui/src/lib/utils/file2base64.ts/0
{ "file_path": "chat-ui/src/lib/utils/file2base64.ts", "repo_id": "chat-ui", "token_count": 142 }
export async function captureScreen(): Promise<string> { let stream: MediaStream | undefined; try { // This will show the native browser dialog for screen capture stream = await navigator.mediaDevices.getDisplayMedia({ video: true, audio: false, }); // Create a canvas element to capture the screenshot ...
chat-ui/src/lib/utils/screenshot.ts/0
{ "file_path": "chat-ui/src/lib/utils/screenshot.ts", "repo_id": "chat-ui", "token_count": 402 }
import { collections } from "$lib/server/database"; import { ObjectId } from "mongodb"; import { describe, expect, it } from "vitest"; import { convertLegacyConversation } from "./convertLegacyConversation"; import { insertLegacyConversation } from "./treeHelpers.spec"; describe("convertLegacyConversation", () => { ...
chat-ui/src/lib/utils/tree/convertLegacyConversation.spec.ts/0
{ "file_path": "chat-ui/src/lib/utils/tree/convertLegacyConversation.spec.ts", "repo_id": "chat-ui", "token_count": 425 }
import { env } from "$env/dynamic/private"; import { Client } from "@gradio/client"; export async function GET({ url }) { if (env.COMMUNITY_TOOLS !== "true") { return new Response("Community tools are not enabled", { status: 403 }); } const space = url.searchParams.get("space"); if (!space) { return new Resp...
chat-ui/src/routes/api/spaces-config/+server.ts/0
{ "file_path": "chat-ui/src/routes/api/spaces-config/+server.ts", "repo_id": "chat-ui", "token_count": 428 }
import { authCondition } from "$lib/server/auth"; import { collections } from "$lib/server/database"; import { MetricsServer } from "$lib/server/metrics.js"; import { error } from "@sveltejs/kit"; import { ObjectId } from "mongodb"; import { z } from "zod"; export async function POST({ params, request, locals }) { co...
chat-ui/src/routes/conversation/[id]/message/[messageId]/vote/+server.ts/0
{ "file_path": "chat-ui/src/routes/conversation/[id]/message/[messageId]/vote/+server.ts", "repo_id": "chat-ui", "token_count": 524 }
<script lang="ts"> import { marked } from "marked"; import privacy from "../../../PRIVACY.md?raw"; </script> <div class="overflow-auto p-6"> <div class="prose mx-auto px-4 pb-24 pt-6 dark:prose-invert md:pt-12"> <!-- eslint-disable-next-line svelte/no-at-html-tags --> {@html marked(privacy, { gfm: true })} </d...
chat-ui/src/routes/privacy/+page.svelte/0
{ "file_path": "chat-ui/src/routes/privacy/+page.svelte", "repo_id": "chat-ui", "token_count": 141 }
import { collections } from "$lib/server/database"; import type { LayoutServerLoad } from "./$types"; import type { Report } from "$lib/types/Report"; export const load = (async ({ locals, parent }) => { const { assistants } = await parent(); let reportsByUser: string[] = []; const createdBy = locals.user?._id ?? ...
chat-ui/src/routes/settings/+layout.server.ts/0
{ "file_path": "chat-ui/src/routes/settings/+layout.server.ts", "repo_id": "chat-ui", "token_count": 258 }
@import "./highlight-js.css"; @tailwind base; @tailwind components; @tailwind utilities; @layer components { .btn { @apply inline-flex flex-shrink-0 cursor-pointer select-none items-center justify-center whitespace-nowrap outline-none transition-all focus:ring disabled:cursor-default; } .active-model { @apply...
chat-ui/src/styles/main.css/0
{ "file_path": "chat-ui/src/styles/main.css", "repo_id": "chat-ui", "token_count": 435 }
{ "license": "Apache-2.0", "creators": [ { "affiliation": "Hugging Face", "name": "Quentin Lhoest" }, { "orcid": "0000-0003-1727-1045", "affiliation": "Hugging Face", "name": "Albert Villanova del Moral" }, { ...
datasets/.zenodo.json/0
{ "file_path": "datasets/.zenodo.json", "repo_id": "datasets", "token_count": 1953 }
# Differences between Dataset and IterableDataset There are two types of dataset objects, a [`Dataset`] and an [`IterableDataset`]. Whichever type of dataset you choose to use or create depends on the size of the dataset. In general, an [`IterableDataset`] is ideal for big datasets (think hundreds of GBs!) due to its ...
datasets/docs/source/about_mapstyle_vs_iterable.mdx/0
{ "file_path": "datasets/docs/source/about_mapstyle_vs_iterable.mdx", "repo_id": "datasets", "token_count": 3730 }
# Load image data Image datasets have [`Image`] type columns, which contain PIL objects. <Tip> To work with image datasets, you need to have the `vision` dependency installed. Check out the [installation](./installation#vision) guide to learn how to install it. </Tip> When you load an image dataset and call the i...
datasets/docs/source/image_load.mdx/0
{ "file_path": "datasets/docs/source/image_load.mdx", "repo_id": "datasets", "token_count": 1388 }
# Process 🤗 Datasets provides many tools for modifying the structure and content of a dataset. These tools are important for tidying up a dataset, creating additional columns, converting between features and formats, and much more. This guide will show you how to: - Reorder rows and split the dataset. - Rename and ...
datasets/docs/source/process.mdx/0
{ "file_path": "datasets/docs/source/process.mdx", "repo_id": "datasets", "token_count": 11695 }
# Use with PyTorch This document is a quick introduction to using `datasets` with PyTorch, with a particular focus on how to get `torch.Tensor` objects out of our datasets, and how to use a PyTorch `DataLoader` and a Hugging Face `Dataset` with the best performance. ## Dataset format By default, datasets return regu...
datasets/docs/source/use_with_pytorch.mdx/0
{ "file_path": "datasets/docs/source/use_with_pytorch.mdx", "repo_id": "datasets", "token_count": 3446 }
from argparse import ArgumentParser from typing import Optional from datasets.commands import BaseDatasetsCLICommand from datasets.hub import convert_to_parquet def _command_factory(args): return ConvertToParquetCommand( args.dataset_id, args.token, args.revision, args.trust_remot...
datasets/src/datasets/commands/convert_to_parquet.py/0
{ "file_path": "datasets/src/datasets/commands/convert_to_parquet.py", "repo_id": "datasets", "token_count": 652 }
# Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
datasets/src/datasets/features/features.py/0
{ "file_path": "datasets/src/datasets/features/features.py", "repo_id": "datasets", "token_count": 41357 }
# Copyright 2020 The HuggingFace Datasets Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
datasets/src/datasets/inspect.py/0
{ "file_path": "datasets/src/datasets/inspect.py", "repo_id": "datasets", "token_count": 6338 }
import itertools from dataclasses import dataclass from typing import Optional import pyarrow as pa import datasets from datasets.table import table_cast logger = datasets.utils.logging.get_logger(__name__) @dataclass class ArrowConfig(datasets.BuilderConfig): """BuilderConfig for Arrow.""" features: Opt...
datasets/src/datasets/packaged_modules/arrow/arrow.py/0
{ "file_path": "datasets/src/datasets/packaged_modules/arrow/arrow.py", "repo_id": "datasets", "token_count": 1641 }
import itertools import warnings from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class PandasConfig(datasets.BuilderConfig): """BuilderConfig for Pandas.""" features: Optional[datasets.Fe...
datasets/src/datasets/packaged_modules/pandas/pandas.py/0
{ "file_path": "datasets/src/datasets/packaged_modules/pandas/pandas.py", "repo_id": "datasets", "token_count": 1040 }
from functools import partial from huggingface_hub import hf_hub_url from huggingface_hub.utils import get_session, hf_raise_for_status hf_dataset_url = partial(hf_hub_url, repo_type="dataset") def check_auth(hf_api, repo_id, token=None): headers = hf_api._build_hf_headers(token=token) path = f"{hf_api.end...
datasets/src/datasets/utils/hub.py/0
{ "file_path": "datasets/src/datasets/utils/hub.py", "repo_id": "datasets", "token_count": 180 }
from collections.abc import Iterator from typing import Iterable class tracked_str(str): origins = {} def set_origin(self, origin: str): if super().__repr__() not in self.origins: self.origins[super().__repr__()] = origin def get_origin(self): return self.origins.get(super()....
datasets/src/datasets/utils/track.py/0
{ "file_path": "datasets/src/datasets/utils/track.py", "repo_id": "datasets", "token_count": 827 }
import textwrap import pyarrow as pa import pytest from datasets import Features, Value from datasets.builder import InvalidConfigName from datasets.data_files import DataFilesList from datasets.packaged_modules.json.json import Json, JsonConfig @pytest.fixture def jsonl_file(tmp_path): filename = tmp_path / "f...
datasets/tests/packaged_modules/test_json.py/0
{ "file_path": "datasets/tests/packaged_modules/test_json.py", "repo_id": "datasets", "token_count": 3820 }
import warnings import pytest import datasets.utils.deprecation_utils from datasets.exceptions import ( ChecksumVerificationError, ExpectedMoreDownloadedFilesError, ExpectedMoreSplitsError, NonMatchingChecksumError, NonMatchingSplitsSizesError, SplitsVerificationError, UnexpectedDownloaded...
datasets/tests/test_exceptions.py/0
{ "file_path": "datasets/tests/test_exceptions.py", "repo_id": "datasets", "token_count": 360 }
import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def add_one(i): # picklable for multiprocessing return i + 1 @require_dill_gt_0_3_2 @require_jo...
datasets/tests/test_parallel.py/0
{ "file_path": "datasets/tests/test_parallel.py", "repo_id": "datasets", "token_count": 825 }
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/api/configuration.md/0
{ "file_path": "diffusers/docs/source/en/api/configuration.md", "repo_id": "diffusers", "token_count": 325 }
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/api/models/autoencoder_oobleck.md/0
{ "file_path": "diffusers/docs/source/en/api/models/autoencoder_oobleck.md", "repo_id": "diffusers", "token_count": 565 }
<!--Copyright 2024 The HuggingFace Team and The InstantX Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by ap...
diffusers/docs/source/en/api/models/controlnet_union.md/0
{ "file_path": "diffusers/docs/source/en/api/models/controlnet_union.md", "repo_id": "diffusers", "token_count": 486 }
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/api/models/transformer2d.md/0
{ "file_path": "diffusers/docs/source/en/api/models/transformer2d.md", "repo_id": "diffusers", "token_count": 465 }